Research suggests that negative news leaves the reader more angry and fearful than it does informed (see Soroka et al., 2015 for a review). This may be most problematic because negative news is more quickly spread on social media than positive news (Brady et al., 2017). These results have implications on the press’ and social media’s ability to accurately inform the public.
# build sample data for display
data_news_sample <- data_news[sample(1:nrow(data_news), size = 132,
prob = sqrt(abs(data_news$sent)), replace = F), ]
d_n_s_fox <- data_news_sample %>% filter(publication == "Fox News")
d_n_s_nyt <- data_news_sample %>% filter(publication == "The New York Times")
d_n_s_cnn <- data_news_sample %>% filter(publication == "CNN")
# build chart
fig <- plot_ly() %>%
layout(title = list(text = "Popular Media Emotion Between 2016 and 2020"))
fig <- fig %>%
add_trace(data = d_n_s_fox, color = I("#002885"),
x = ~sent, y = ~year.cont, yaxis = "y2", name = ~publication,
text = paste0("<b>", d_n_s_fox$publication,
"</b><br><br>Article: <i>",
d_n_s_fox$title,
"</i><br>URL: <a href='",
d_n_s_fox$url, "'>",
substr(d_n_s_fox$url, 0, 30),
"...</a>"),
hovertemplate = "%{text}") %>%
add_trace(data = d_n_s_nyt, color = I("#555555"),
x = ~sent, y = ~year.cont, yaxis = "y2", name = ~publication,
text = paste0("<b>", d_n_s_nyt$publication,
"</b><br><br>Article: <i>",
d_n_s_nyt$title,
"</i><br>URL: <a href='",
d_n_s_nyt$url, "'>",
substr(d_n_s_nyt$url, 0, 30),
"...</a>"),
hovertemplate = "%{text}") %>%
add_trace(data = d_n_s_cnn, color = I("#EC2029"),
x = ~sent, y = ~year.cont, yaxis = "y2", name = ~publication,
text = paste0("<b>", d_n_s_cnn$publication,
"</b><br><br>Article: <i>",
d_n_s_cnn$title,
"</i><br>URL: <a href='",
d_n_s_cnn$url, "'>",
substr(d_n_s_cnn$url, 0, 30),
"...</a>"),
hovertemplate = "%{text}") %>%
layout(
xaxis = list(title = "Article Emotion", tickmode = "array",
nticks = 2, tickvals = c(-1, 1),
ticktext = c("More Negative", "More Positive")),
xaxis2 = list(title = "Left"),
yaxis = list(title = "News Source"),
yaxis2 = list(title = "Year", overlaying = "y", side = "right", autotick = F, dtick = 1),
legend = list(x = 1.1)
)
fig <- fig %>% add_trace(data = data_news %>% filter(publication == "Fox News"), color = I("#002885"),
x = ~sent, name = "Fox", type = "violin", hoveron="points", box = list(visible = T))
fig <- fig %>% add_trace(data = data_news %>% filter(publication == "The New York Times"), color = I("#555555"),
x = ~sent, name = "NYT", type = "violin", hoveron="points", box = list(visible = T))
fig <- fig %>% add_trace(data = data_news %>% filter(publication == "CNN"), color = I("#EC2029"),
x = ~sent, name = "CNN", type = "violin", hoveron="points", box = list(visible = T))
fig
NOTES:
# creating a continuous measure of time
data_news$year.cont <- data_news$year + ((data_news$month - 1) / 12) + data_news$day / 365
# computing weighted average of title sentiment (with valence direction)
data_news$title.sent <- ifelse((data_news$title.pos.sent + data_news$title.neg.sent + data_news$title.neu.sent) == 0, 0, (data_news$title.pos.sent - data_news$title.neg.sent) / (data_news$title.pos.sent + data_news$title.neg.sent + data_news$title.neu.sent))
# computing weighted average of article sentiment (with valence direction)
data_news$article.sent <- ifelse((data_news$article.pos.sent + data_news$article.neg.sent + data_news$article.neu.sent) == 0, 0, (data_news$article.pos.sent - data_news$article.neg.sent) / (data_news$article.pos.sent + data_news$article.neg.sent + data_news$article.neu.sent))
# computing weighted average of title sentiment (with direction)
data_news$sent <- data_news$title.sent + data_news$article.sent